package com.qqtech.qquan.hi.controller;

import javax.annotation.Resource;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qqtech.core.common.enums.YesNoEnum;
import com.qqtech.core.frame.model.PageKit;
import com.qqtech.core.frame.model.PageOrder;
import com.qqtech.core.frame.model.Result;
import com.qqtech.core.frame.service.BaseService;
import com.qqtech.qquan.hi.model.HiUpgrade;
import com.qqtech.qquan.hi.model.HiUpgradeQuery;
import com.qqtech.qquan.hi.model.HiUpgradeVo;
import com.qqtech.qquan.hi.service.HiUpgradeService;
import com.qqtech.web.context.BaseWebController;

@Controller
@RequestMapping(value = "/hi/upgrade")
public class HiUpgradeController extends BaseWebController<HiUpgrade, HiUpgradeQuery> {
	@Resource
	private HiUpgradeService hiUpgradeService;

	@Override
	protected BaseService<HiUpgrade> getBaseService() {
		return hiUpgradeService;
	}

	/**
	 * 分页
	 * 
	 * @param HiUpgradeQuery
	 * @return
	 */
	@RequestMapping(value = "/page")
	@ResponseBody
	public Result page(@RequestBody HiUpgradeQuery query) {
		Result ret = new Result();
		query.setStatus(YesNoEnum.YES.getCode());
		Pageable pageKit = new PageKit(query.getPage(), new PageOrder(Direction.ASC, "oidx"));
		Page<HiUpgradeVo> page = hiUpgradeService.queryPageList(query, pageKit);
		ret.put("page", page);
		return ret;
	}

	@RequestMapping(value = "/detail")
	@ResponseBody
	public Result detail(@RequestBody HiUpgradeQuery query) {
		Result ret = new Result();
		HiUpgradeVo detail = hiUpgradeService.getById(query.getId());
		ret.put("detail", detail);
		return ret;
	}
}
